/*
 * @lc app=leetcode.cn id=190 lang=csharp
 *
 * [190] 颠倒二进制位
 */

// @lc code=start
public class Solution {
    const int M1 = 0x55555555;
    const int M2 = 0x33333333;
    const int M4 = 0x0f0f0f0f;
    const int M8 = 0x00ff00ff;
    public uint reverseBits(uint n) {
        n = n >> 8 & M8 | (n & M8) << 8;
        n = n >> 4 & M4 | (n & M4) << 4;
        n = n >> 2 & M2 | (n & M2) << 2;
        n = n >> 1 & M1 | (n & M1) << 1;
        return (n >> 16 | n << 16);
    }
}
// @lc code=end

